import Koa from "koa"
import koaBody from "koa-bodyparser"
import koaStatic from "koa-static"
import koaJson from "koa-json"
import koaCompose from "koa-compose"
import koaCompress from "koa-compress"
import koaHelmet from "koa-helmet"
import Router from "koa-router"
import cors from "@koa/cors"
import path from "path"
import ErrorHandle from '@/middleware/ErrorHandle'
import initRoutes from "@/routes/index"
import Logger from "./helper/Logger"

const router = new Router();

const app = new Koa();

const middleware = koaCompose([
    cors(),
    koaCompress(),
    koaBody(),
    koaStatic(path.resolve(__dirname,'./../public')),
    koaJson({pretty:false,param:'pretty'}),
    koaHelmet(),
    ErrorHandle,
]);

app.use(middleware);

initRoutes(app, router)

app.listen(3030);